package org.xlh.springboot.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@Component
public class SomeBean {

    @Autowired
    private Environment env;

    public void doSome(){
        //直接使用环境对象，获取环境信息，配置信息等
        String[] activeProfiles = env.getActiveProfiles();
        for (String profile : activeProfiles) {
            System.out.println(profile);
        }

        //获取配置信息
        String username = env.getProperty("myapp.username");
        System.out.println(username);
    }
}
